package cn.zsb.zsb.ctrl;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

/**
 * @author oldliu
 * @since 1.0
 */
@Controller
@RequestMapping("test")
public class HelloController {
    @GetMapping("hello")
    public ModelAndView sayhi(){
        ModelAndView mv=new ModelAndView();
        mv.addObject("msg","欢迎来到spring mvc");
        //mv.setViewName("hello.jsp");//没有 /，test/hello.jsp
        mv.setViewName("hello");
        return mv;
    }

    @GetMapping("hi")
    public String wenhou(Model mv){

        mv.addAttribute("msg","欢迎来到spring mvc");
        return "hello";
       // return "forward:/hello.jsp";
    }
}
